package Views;

import Views.Base.BaseViewCreateUser;
import Source.CreateUser;
import UCM.UCCreateUser;

/**
 * Creates the create user panel interface
 * @author Josh
 */
public class ViewCreateUser extends BaseViewCreateUser {

    private final UCCreateUser UCCreateUser = new UCCreateUser(this);
    private CreateUser model;

    public ViewCreateUser() {        
        createUserButton.addActionListener(new AdapterUCCToAL(UCCreateUser));
    }

    /**
     * Gives the view a pointer to the model.
     * @param model
     */
    public void loadTo(CreateUser model) {
        this.model = model;
    }

    /**
     * Sets the data in the model.
     */
    public void setModelData() {
        model.setUser(user.getText());
        model.setPassword(new String(password.getPassword()));
        model.setConfirmPassword(new String(confirmPassword.getPassword()));
        model.setFirstName(firstName.getText());
        model.setLastName(lastName.getText());
        model.setAddress(address.getText());
    }

    public void updateIncorrectInput() {
        ViewMain.getInstance().updateMsg("Inappropriate Information entered by User.");
    }

    /**
     * updates the login
     */
    public void updateLogin() {
        ViewMain.getInstance().updateLoginUser();
    }
}

